﻿/**********************************************************************
 * @file   FITKAbstractJunction.h
 * @brief  Junction抽象类和管理器声明
 * @author liuzhonghua (liuzhonghuaszch@163.com)
 * @date   2025-01-21
 *********************************************************************/
#ifndef _FITK_ABSTRACT__JUNCTION_H___
#define _FITK_ABSTRACT__JUNCTION_H___
 
#include "FITK_Kernel/FITKCore/FITKAbstractNDataObject.h"
#include "FITK_Kernel/FITKCore/FITKAbstractDataManager.hpp"
#include "FITKAcousticsModelAPI.h"

namespace Acoustics
{
    /**
     * @brief  交界处耦合抽象基类
     * @author liuzhonghua (liuzhonghuaszch@163.com)
     * @date   2025-01-21
     */
    class FITKAcousticsModelAPI FITKAbstractJunction :
        public Core::FITKAbstractNDataObject
    {
        Q_OBJECT
    public:
        /**
         * @brief  耦合对象类型
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-01-21
         */
        enum JunctionType
        {
            NoneJunction,            ///< 无
            SEAPointJunction,        ///< SEA点交界处耦合连接
            SEALineJunction,         ///< SEA线交界处耦合连接
            SEAAreaJunction,         ///< SEA面交界处耦合连接
            HybridPointJunction,     ///< 混合点交界处耦合连接
            HybridLineJunction,      ///< 混合线交界处耦合连接
            HybridAreaJunction,      ///< 混合面交界处耦合连接
            FEPointJunction,         ///< FE点交界处耦合连接
            FELineJunction,          ///< FE线交界处耦合连接
            FEAreaJunction,          ///< FE面交界处耦合连接
        };
        Q_ENUM(JunctionType);

    public:
        /**
         * @brief  Construct a new FITKAbstractJoint object
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-01-21
         */
        explicit FITKAbstractJunction() = default;
        /**
         * @brief  Destroy the FITKAbstractJoint object
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-01-21
         */
        virtual ~FITKAbstractJunction();
         /**
          * @brief  获取耦合对象类型
          * @return JunctionType 
          * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date    2025-01-21
          */
        virtual JunctionType getJunctiontType() = 0;
        /**
         * @brief    初始化连接子系统信息
         * @param[i] subSysIdList     子系统链表
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-01-21
         */
        void initConnect(QList<int>& subSysIdList);
        /**
         * @brief    添加连接子系统
         * @param[i] subSysId          子系统id
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-01-21
         */
        void appendConnect(int subSysId);
        /**
         * @brief    获取是否启用连接
         * @return   bool      是否启用
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-01-21
         */
        bool getEnabledJunction();
        /**
         * @brief    设置是否启用连接
         * @param[i] enabled   是否启用
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-01-21
         */
        void setEnabledJunction(bool enabled);
        /**
         * @brief    获取子系统id列表
         * @return   QList<int>     子系统id列表
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-01-21
         */
        QList<int> getSubSysIds();

    protected:
        /**
         * @brief    更新连接
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-01-21
         */
        virtual void updateConnect() = 0;

    protected:
        /**
         * @brief  是否启用连接
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-01-21
         */
        bool _enabledJunction = true;
        /**
         * @brief  子系统ID链表
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-01-21
         */
        QList<int> _subSysIDList{};
    };


    /**
     * @brief  耦合对象管理器
     * @author liuzhonghua (liuzhonghuaszch@163.com)
     * @date   2025-01-21
     */
    class FITKAcousticsModelAPI FITKJunctionManager : 
        public Core::FITKAbstractDataManager<FITKAbstractJunction>
    {
    public:
        /**
         * @brief  Construct a new FITKJunctionManager object
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-01-21
         */
        explicit FITKJunctionManager() = default;
        /**
         * @brief  Destroy the FITKJunctionManager object
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-01-21
         */
        virtual ~FITKJunctionManager() = default;
        /**
         * @brief 获取指定类型的耦合对象列表
         * @param[i]  t             耦合对象类型
         * @return QList<FITKSEAAbstractJunction*> 
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-01-21
         */
        QList<FITKAbstractJunction*> getJointsByType(FITKAbstractJunction::JunctionType t);
        /**
         * @brief    获取连接对象-通过连接类型和子系统的数据一致
         * @param[i] t            连接类型
         * @param[i] subSysIds    连接id
         * @return   FITKAbstractJunction *
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-01-21
         */
        FITKAbstractJunction* getJunction(FITKAbstractJunction::JunctionType t, QList<int>& subSysIds);
    };
}

#endif